<!DOCTYPE html>
<html>

	<head>

		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>H+ 后台主题UI框架 - 空白页</title>
		<meta name="keywords" content="">
		<meta name="description" content="">

		<!-- <link rel="shortcut icon" href="favicon.ico"> -->
		<!-- <link rel="shortcut icon" href="favicon.ico"> -->
		<link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
		<link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
		<link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
		<!-- jqgrid-->
		<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
		<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
		<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
		<link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
		<link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
		<style>
			.radio-inline input[type=radio] {
				margin-top: 4px
			}
			
			.borRed {
				border: 1px solid red;
				padding: 4px;
			}
			
			.textBorder {
				border-color: red
			}
		</style>
	</head>

	<body style="color:#333;padding:3px;" class="x_sorll">
		<!-- 标题 -->
		<div class="page-heade">
			<h2 class="title_color text-center">TI费用核销申请-查询</h2>
		</div>
		<!-- 标题 -->
		<div>
			<form action="#" method="post" class="form-inline" id="f1">

				<table class="table table-bordered bud_hei" style="margin-top:0">
					<tr>
						<td><span class="font-bold">您选择的经销商是：安顺市新城区天金副食经销部(CU00110)</span>
							<a class="btn btn-warning" href="{:url('other/alltiverify_list')}">点击返回上一步</a>&nbsp;&nbsp;
							  <a href="{:url('ti_apply/genhuanjingxiao')}" class="btn-info btn ">点击更换经销商</a>
						</td>
					</tr>
					<tr>
						<td>
							<a href="{:url('other/new_tmphexiao')}" class="btn btn-primary">可核销</a>
							<a href="{:url('other/new_tmphexiao')}" class="btn btn-primary">核销中</a>
							<a href="{:url('other/new_tmphexiao')}" class="btn btn-primary">不予核销</a>
							<a href="{:url('other/new_tmphexiao')}" class="btn btn-primary">未反馈</a>
							<a href="{:url('other/new_tmphexiao')}" class="btn btn-primary">反馈中</a>
							<a href="#" class="btn btn-primary">未核查</a>
							<a href="#" class="btn btn-primary">已锁定</a>
						</td>
					</tr>
					<tr>
						<td class="colorRed">温馨提示：一旦核销，原申请整单都不允许再做异动、取消、反馈。谢谢</td>
					</tr>
					<tr>
						<td class="font-bold">请选择下列要核销的记录后，点击"生成核销面单预览"按钮后即可核销。</td>
					</tr>
				</table>
				<table class="table table-striped table-bordered bud_hei text-center">
					<tr class="info">
						<th class="text-center" rowspan="2">序号</th>
						<th class="text-center" rowspan="2"><input type="checkbox" id="checkAll" checked class="form-control"></th>
						<th class="text-center" rowspan="2">申请人</th>
						<th class="text-center" rowspan="2">原申请文件</th>
						<th class="text-center" rowspan="2">明细编号</th>
						<th class="text-center" rowspan="2">核查结果</th>
						<th class="text-center" rowspan="2">网点名称</th>
						<th class="text-center" rowspan="2">系统名称</th>
						<th class="text-center" rowspan="2">产品</th>
						<th class="text-center" rowspan="2">三级费用科目</th>
						<th class="text-center" colspan="3">实际投入</th>
						<th class="text-center" colspan="8">本次申请核销</th>
						<th class="text-center" rowspan="2">余额不予核销</th>
						<th class="text-center" rowspan="2">活动开始日期</th>
						<th class="text-center" rowspan="2">支付方式</th>
						<th class="text-center" rowspan="2">备注</th>
						<th class="text-center" rowspan="2">操作</th>
					</tr>
					<tr class="info">
						<th class="text-center">实际投入金额(未税)</th>
						<th class="text-center">已核销金额</th>
						<th class="text-center">未核销金额</th>
						<th class="text-center">未税核销金额</th>
						<th class="text-center">
							有无发票<br><button type="button" class="btn-info" id="is_fap">批量设置</button>
						</th>
						<th class="text-center">
							发票号<span class="colorRed font-bold">?</span><br><button type="button" class=" btn-info" id="setFpNum" title="注：此功能为批量设置发票号。批量设置发票号后，选中的所有明细的‘有无发票’一列都将变为‘有’，发票号都将统一改为输入的发票号">批量设置</button>
						</th>
						<th class="text-center">
							发票是否<br>(可抵扣)<span class="colorRed font-bold">?</span>
						</th>
						<th class="text-center">
							税率<span class="colorRed font-bold">?</span>
						</th>
						<th class="text-center">税金</th>
						<th class="text-center">含税核销金额</th>
						<th class="text-center">实际投入金额</th>
					</tr>
					<tr>
						<td>1</td>
						<td><input type="checkbox" name="dids[]" value="" checked class="form-control cksdid"></td>
						<td>蔡启豪</td>
						<td>
							<a href="javascript:;" onclick="xiangqing()">201805310008</a>
						</td>
						<td>201805310008_1 <span><i class="fa fa-info-circle colorRed"></i>未检测</span></td>
						<td>无</td>
						<td>
							<a href="javascript:;">万家天河公园分店</a>
						</td>
						<td>
							<a href="javascript:;">广东华润万家</a>
						</td>
						<td><span class="font-bold">单品：</span>40克舒爽爱牙乐儿童牙膏草莓味</td>
						<td>经销商特价补差</td>
						<td class="ObjectNum num2i ">2400</td>
						<td class="ObjectNum num2i">0</td>
						<td class="ObjectNum num2i weihec">2400</td>
						<td><input type="text" class="form-control heweishui" value="2400.00" name="weishui[]" style="min-width: 80%;width: 80%"></td>
						<td>
							<div class="form-group radioDiv">
								<label class="radio-inline">
              						<input type="radio" name="isfa1" class="fashi" value="0" >有
            					</label>
								<label class="radio-inline">
                  					<input type="radio" name="isfa1" class="fafou" value="1">后补
            					</label>
								<label class="radio-inline">
                  					<input type="radio" name="isfa1" class="fafou1" value="2">无且不补
            					</label>
							</div>
						</td>
						<td><input type="text" name="fapiao[]" class="form-control fapiao"></td>
						<td>
							<div class="form-group">
								
								<label class="radio-inline">
                					<input type="radio" name="dikou1" checked  class="dikoushi" value="1" >是
              					</label>
								<label class="radio-inline">
                    				<input type="radio" name="dikou1" class="dikoufou" value="0" checked >否
              					</label>

							</div>
						</td>
						<td><input type="text" style="min-width: 60px;width: 60px;" class="form-control shuilv  num2" value="" name="shuilv[]">%</td>
						<td><input type="text" style="min-width: 80px;width: 80px;" class="form-control shuijins  num2" value=""></td>
						<td><input type="text" class="form-control  num2" placeholder="" name="" value="" readonly></td>
						<td><input type="text" class="form-control num2" placeholder="" value="" readonly></td>
						<td><input type="checkbox" name="yuebuhe[]" class="form-control yuebuhe" value=""></td>
						<td><input type="text" class="form-control layer-date" value=""></td>
						<td>
							<select name="zfid[]" class="form-control zfid">
								
								<option value='' selected></option>
								
								<option value=''></option>
								
							</select>
						</td>
						<td><input type="text" name="beizhu[]" class="form-control"></td>
						<td><button type="button" class="btn-info" onclick="buyuhexiao()">本条不予核销</button></td>
					</tr>
				
				</table>
				<table class="table-bordered table">
					<tr>
						<td rowspan="3" class="text-center" style="min-width: 120px;width: 120px">备注:</td>
						<td><textarea name="zongbeizhu" id="" class="form-control" style="width: 60%;overflow: auto;"></textarea><span style="vertical-align: bottom;">(500)</span></td>
					</tr>
				</table>
				<p class="colorRed">温馨提示：<br> 1.如果有明细单不需要核销，请在该费用明细最后面点击："本条不予核销"按钮。
					<br> 2.如核销一部分，所剩费用余额不需要核销,请勾选："余额不予核销"。
				</p>
				<br><br><br><br><br><br> 
				<div class="footer fixed_full text-center" style="height: auto;border:0;padding: 0;margin-bottom: 20px;">
					<table class="table-bordered table text-center" style="margin:0;padding: 0;background: #f3f3f4">
						<tr>
							<td>未税金额合计：<span class="colorRed font-bold ObjectNum" id="wszonge">0</span>元；<button type="button" class="btn-primary btn" id="modify_notax">修改未税金额</button></td>
							<td>税金合计：<span class="colorRed font-bold ObjectNum" id="sjzonge">0</span>元；<button type="button" class="btn-primary btn" id="setFpInfo">设置发票信息</button></td>
							<td rowspan="2">
								<button type="button" class="btn-primary btn" id="create_verify_yl">生成核销申请预览</button>
							</td>
						</tr>
						<tr>
							<td>含税税金额合计：<span class="colorRed font-bold ObjectNum" id="hszong">0</span>元；<button type="button" class="btn-primary btn" id="modify_tax">修改含税金额</button></td>
							<td><input name="items1" type="checkbox" id="checkboxAll1">设置余额不予核销</td>
						</tr>
					</table>
				</div>
			
			</form>
		</div>
		<script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
		<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
		<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
		<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
		<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
		<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
		<script src="__STATIC__/layout/js/common.js"></script>
		<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
		<script>
			//详情也
			function xiangqing(aid) {
				var index = layer.open({
					type: 2,
					title: '常规促销申请',
					area: ['100%', '100%'],
					maxmin: true,
					content: '{:url("apply_de")}?aid=' + aid
				})
			}

			function tongbukou() {
				$(".cksdid").each(function() {
					if($(this).prop("checked")) {
						$(this).parent().nextAll().eq(19).children().prop("checked", true);
					} else {
						$(this).parent().nextAll().eq(19).children().prop("checked", false);
					}
				})
			}
			$("#checkboxAll1").change(function() {
				var ck = $(this);
				if($(this).prop("checked")) {
					swal({
							title: "提示",
							text: "您确定设置选定的余额不再核销吗？如确定则余额自动释放回预算池。请确认!",
							type: "warning",
							showCancelButton: true,
							confirmButtonColor: "#FF3333",
							confirmButtonText: "确定",
							cancelButtonText: "取消",
							closeOnConfirm: true
						}, function(isConfirm) {
							if(isConfirm) {
								$(".yuebuhe").attr("onclick", "return false");
								tongbukou();

							} else {
								$(".yuebuhe").attr("onclick", "return true");
								ck.prop("checked", false);
							}

						}

					)
				} else {
					$(".yuebuhe").attr("onclick", "return true");
					$(".yuebuhe").prop("checked", false);
				}

			})

			//全选
			$("#checkAll").change(function() {
				if($(this).prop("checked")) {
					$(".cksdid").prop("checked", true);
				} else {
					$(".cksdid").prop("checked", false);
				}
				if($("#checkboxAll1").prop("checked"))
					tongbukou();
				jisuanzongshu();
			})
			$(".cksdid").change(function() {
				var flag = 1;
				$(".cksdid").each(function() {
					if(!$(this).prop("checked")) {
						flag = 0;
					}
				})
				if(flag == 1) {
					$("#checkAll").prop("checked", true);
				} else {
					$("#checkAll").prop("checked", false);
				}
				if($("#checkboxAll1").prop("checked"))
					tongbukou();
				jisuanzongshu();
			});
			jisuanzongshu();

			function jisuanzongshu() {
				var zongweishui = 0;
				var zonghanshui = 0;
				var zongshuijin = 0;
				$(".cksdid").each(function() {

					if($(this).prop("checked")) {
						zongweishui += parseFloat(parseFloat($(this).parent().nextAll().eq(11).children().val()).toFixed(2));
						zonghanshui += parseFloat(parseFloat($(this).parent().nextAll().eq(17).children().val()).toFixed(2));
						zongshuijin += parseFloat(parseFloat($(this).parent().nextAll().eq(16).children().val()).toFixed(2));
					}
				})
				$("#sjzonge").html(zongshuijin.toFixed(2));
				$("#hszong").html(zonghanshui.toFixed(2));
				$("#wszonge").html(zongweishui.toFixed(2));

			}

			function buyuhexiao(did) {

				$.post("{:url('TiApply/dantiaomingxi')}", {
					did: did
				}, function(re) {
					var data = JSON.parse(re);
					var fankui = parseFloat(data["fankuijine"]).toFixed(2);
					var hexiao = parseFloat(data["hexiao"]).toFixed(2);
					var weihe = parseFloat(data["weihe"]).toFixed(2);
					swal({
							title: "提示",
							text: "实际投入金额为：" + fankui + ",已核销金额为：" + hexiao + ",未核销金额为：" + weihe + ",确定后不予核销金额为：" + weihe + "请确认是否不予核销该金额再点击确定",
							type: "warning",
							showCancelButton: true,
							confirmButtonColor: "#FF3333",
							confirmButtonText: "是的不予核销",
							cancelButtonText: "取消",
							closeOnConfirm: true
						},
						function(isConfirm) {
							if(isConfirm) {
								$.post("{:url('TiApply/nohexiao')}", {
									did: did,
									state: 1
								}, function(datas) {
									//alert(datas);

									var res1 = JSON.parse(datas);
									if(res1["state"] == 1) {
										swal({
											title: "完成",
											text: "操作已成功",
											type: "success"
										}, function() {

											location.href = location.href;
										});

									} else {
										swal({
											title: "错误",
											text: res1["msg"],
											type: "warning"
										});
									}
								})
							}
						})
				})
			}
			$(".heweishui").blur(function() {
				if(isNaN(parseFloat($(this).val()))) {
					$(this).val("0.00");
				} else {
					$(this).val(parseFloat($(this).val()).toFixed(2));
				}
				var shuilv = $(this).parent().next().next().next().next().children().val();
				if(shuilv != "") {
					shuilv = parseFloat(shuilv);
					var price = parseFloat($(this).val());
					var shuijin = (price * shuilv / 100).toFixed(2);
					var zonge = (price + parseFloat(shuijin)).toFixed(2);
					var vat = $(this).parent().next().next().next().children().eq(0).children().eq(0).val();
					//alert(vat);
					if(vat == 1)
						var sj = price.toFixed(2);
					else
						var sj = zonge;
					$(this).parent().next().next().next().next().next().next().next().children().val(sj);
					$(this).parent().next().next().next().next().next().children().val(shuijin);
					$(this).parent().next().next().next().next().next().next().children().val(zonge);
				}
				jisuanzongshu();
			})
			$(".shuijins").blur(function() {
				if(isNaN(parseFloat($(this).val()))) {
					$(this).val("0.00");
				} else {
					$(this).val(parseFloat($(this).val()).toFixed(2));
				}
				var price = $(this).parent().prev().prev().prev().prev().prev().children().val();
				if(price != "") {
					price = parseFloat(price);
					var shuijin = parseFloat($(this).val());
					var shuilv = (shuijin / price * 100).toFixed(2);

					var zonge = (price + parseFloat(shuijin)).toFixed(2);
					var vat = $(this).parent().prev().prev().children().eq(0).children().eq(0).val();
					if(vat == 1)
						var sj = price.toFixed(2);
					else
						var sj = zonge;
					$(this).parent().next().next().children().val(sj);
					$(this).parent().prev().children().val(shuilv);
					$(this).parent().next().children().val(zonge);

				}
				jisuanzongshu();
			})
			$(".num2").each(function() {
				$(this).val(parseFloat($(this).val()).toFixed(2));
			})
			$(".shuilv").blur(function() {
				if(isNaN(parseFloat($(this).val()))) {
					$(this).val("0.00");
				} else {
					$(this).val(parseFloat($(this).val()).toFixed(2));
				}
				var price = $(this).parent().prev().prev().prev().prev().children().val();
				if(price != "") {
					price = parseFloat(price);
					var shuilv = parseFloat($(this).val());
					var shuijin = (price * shuilv / 100).toFixed(2);
					var zonge = (price + parseFloat(shuijin)).toFixed(2);
					var vat = $(this).parent().prev().children().eq(0).children().eq(0).val();
					if(vat == 1)
						var sj = price.toFixed(2);
					else
						var sj = zonge;
					$(this).parent().next().next().next().children().val(sj);
					$(this).parent().next().children().val(shuijin);
					$(this).parent().next().next().children().val(zonge);
				}
				jisuanzongshu();
			})
			$(".fafou").change(function() {
				if($(this).prop("checked")) {
					$(this).parent().parent().parent().next().children().val("").prop("readonly", true);
					$(this).parent().next().val(0);
				}
			})
			$(".fashi").change(function() {
				if($(this).prop("checked")) {
					$(this).parent().parent().parent().next().children().val("").prop("readonly", false);
					$(this).parent().next().next().val(1);
				}
			})
			$(".dikoufou").change(function() {
				if($(this).prop("checked")) {

					$(this).parent().parent().children().eq(0).val(0);
					var hanshui = parseFloat($(this).parent().parent().parent().next().next().next().children().val());
					$(this).parent().parent().parent().next().next().next().next().children().val(hanshui.toFixed(2))
				}
			})
			$(".dikoushi").change(function() {
				if($(this).prop("checked")) {

					$(this).parent().parent().children().eq(0).val(1);
					var weishui = parseFloat($(this).parent().parent().parent().prev().prev().prev().children().val());
					$(this).parent().parent().parent().next().next().next().next().children().val(weishui.toFixed(2))
				}
			})

			$(document).ready(function() {

				/*设置发票信息*/

				/*进入按网点反馈页面*/
				$("#toNetFk").click(function() {
					var _$this = this
					swal({
							title: "",
							text: "页面跳转后，当前页面已编辑的数据将不被保存，您确定跳转吗？",
							type: "warning",
							showCancelButton: true,
							confirmButtonColor: "#DD6B55",
							confirmButtonText: "确定",
							cancelButtonText: "取消",
							closeOnConfirm: false,
							closeOnCancel: false
						},
						function(isConfirm) {
							if(isConfirm) {
								// console.log(_$this);
								swal("", "", "success");
								location.href = "ROIjcyj.html"
							} else {
								swal("取消！", "", "error");
							}
						});
				})
				/*设置checkbox*/
				/*checkbox选择*/
				$("#checkAll").click(function() {

					$("[name=items]:checkbox").prop("checked", $(this).prop("checked"));
					if($("[name=items]:checkbox").prop("checked") != true) {
						// console.log($(this))
						$("[name=items]:checkbox").parents("tr").css("backgroundColor", "#fff")
					} else {
						$("[name=items]:checkbox").parents("tr").css("backgroundColor", "#f8f800")

					}
				})
				$("[name=items]:checkbox").click(function() {
					//定义一个临时变量，避免重复使用同一个选择器选择页面中的元素，提高程序效率
					// console.log(1)
					var $tmp = $("[name=items]:checkbox");
					if($(this).prop("checked") != true) {
						// console.log($(this))
						$(this).parent().parent().css("backgroundColor", "#fff")
					} else {
						$(this).parent().parent().css("backgroundColor", "#f8f800")

					}
					//用filter()方法筛选出选中的复选框，并直接给CheckedAll赋值
					$("#checkAll").prop('checked', $tmp.length == $tmp.filter(':checked').length);

				})
				/*设置有无发票*/
				$("#is_fap").click(function() {
					var str = '<form  class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">批量设置有无发票</th></tr><tr><td style="min-width:120px;width:120px;" class="text-center">有无发票<span class="colorRed">*</span></td><td><label class="radio-inline"><input type="radio" name="inlineRadioOptionse" value="0" >有</label><label class="radio-inline"><input type="radio" name="inlineRadioOptionse" checked value="1">后补</label><label class="radio-inline"><input type="radio" name="inlineRadioOptionse" checked value="2">无且不补</label></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" id="fapiaoqd" class="btn btn-success" value="确定"><input type="button" class="btn btn-warning" value="返回" id="cancelBack" style="margin-left:20px"></div></form>'
					layer.open({
						type: 1,
						title: "",
						skin: 'layui-layer-rim', //加上边框
						area: ['500px', '300px'], //宽高
						content: str
					});
					var cancelBack = document.getElementById('cancelBack')
					cancelBack.onclick = function() {
						layer.closeAll();
					}
					var fapiaoqd = document.getElementById('fapiaoqd')
					fapiaoqd.onclick = function() {
						var vals = $("input[name='inlineRadioOptionse']:checked").val();
						// alert(vals);
						if(vals == 0) {
							$(".fashi").prop("checked", true);
							$(".fapiao").val("").prop("readonly", true);
							$(".isfa1").val(0);
						} else if(vals == 1){
							$(".fafou").prop("checked", true);
							$(".fapiao").prop("readonly", false);
							$(".isfa1").val(1);
						}else{
							$(".fafou1").prop("checked", true);
							$(".fapiao").prop("readonly", false);
							$(".isfa1").val(2);
						}
						layer.closeAll();
					}
				})
				/*修改未税金额*/
				$("#modify_notax").click(function() {
					var zongweishui = 0;
					var zongweihe = 0;
					$(".cksdid").each(function() {

						if($(this).prop("checked")) {
							zongweishui += parseFloat(parseFloat($(this).parent().nextAll().eq(11).children().val()).toFixed(2));
							zongweihe += parseFloat(parseFloat($(this).parent().nextAll().eq(10).html().replace(',', '')).toFixed(2));
						}
					})
					zongweishui = parseFloat(zongweishui).toFixed(2);
					zongweihe = parseFloat(zongweihe).toFixed(2);
					var str = '<form method="get" class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">TI核销修改未税金额</th></tr><tr><td style="min-width:140px;width:140px;" class="text-center">原未税金额(元)</td><td><span class="ObjectNum">' + zongweishui + '</span></td></tr><tr><td style="min-width:140px;width:140px;" class="text-center">修改后未税金额(元)</td><td><input type="text" id="newweishui" class="form-control" style="min-width:100px;width:100px;"/><span style="display:none;color:red" id="tsweishui">金额不能为空</span></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" class="btn btn-success" id="qdweishui" value="确认提交"><input type="button" class="btn btn-warning" value="关闭返回" id="cancelBack" style="margin-left:20px"></div></form>'
					layer.open({
						type: 1,
						title: "TI核销修改未税金额",
						skin: 'layui-layer-rim', //加上边框
						area: ['500px', '300px'], //宽高
						content: str
					});
					var cancelBack = document.getElementById('cancelBack')
					cancelBack.onclick = function() {
						layer.closeAll();
					}
					var newweishui = document.getElementById("newweishui")
					newweishui.onblur = function() {
						if(!isNaN(parseFloat(this.value))) {
							this.value = parseFloat(this.value).toFixed(2);
						} else {
							this.value = "";

						}
					}
					var qdweishui = document.getElementById('qdweishui')
					qdweishui.onclick = function() {

						if($("#newweishui").val() == "") {
							$("#tsweishui").show();

						} else {
							$("#tsweishui").hide();
							var xian = parseFloat($("#newweishui").val());
							var bili = xian / zongweihe;
							// alert(bili);
							$(".cksdid").each(function() {

								if($(this).prop("checked")) {
									var price = parseFloat($(this).parent().nextAll().eq(10).html().replace(',', ''));
									//alert(price);
									var nejisuanpri = parseFloat(price * bili);
									var newprice = nejisuanpri.toFixed(2);
									$(this).parent().nextAll().eq(11).children().val(newprice);
									var shuilv = parseFloat($(this).parent().nextAll().eq(15).children().val());
									var sj = parseFloat(nejisuanpri * shuilv / 100);
									$(this).parent().nextAll().eq(16).children().val(sj.toFixed(2));
									var zhs = sj + nejisuanpri;
									$(this).parent().nextAll().eq(17).children().val(zhs.toFixed(2));
									var vat = $(this).parent().nextAll().eq(14).children().eq(0).children().eq(0).val();
									if(vat == 1)
										var sj = newprice;
									else
										var sj = zhs.toFixed(2);
									$(this).parent().nextAll().eq(18).children().val(sj);
								}
							})
							jisuanzongshu();
							layer.closeAll();
						}
						// layer.closeAll(); 
					}
				})
				/*修改含税金额*/
				$("#modify_tax").click(function() {
					var hanshuisz = 0;
					var zonghanshui = 0;
					$(".cksdid").each(function() {

						if($(this).prop("checked")) {

							var weihes = parseFloat($(this).parent().nextAll().eq(10).html().replace(',', ''));
							var shuilv = parseFloat($(this).parent().nextAll().eq(15).children().val());
							hanshuisz += parseFloat(weihes + weihes * shuilv / 100);
							zonghanshui += parseFloat($(this).parent().nextAll().eq(17).children().val());
						}

					})
					//alert(hanshuisz);
					var str = '<form method="get" class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">TI核销修改含税金额</th></tr><tr><td style="min-width:140px;width:140px;" class="text-center">原含税金额(元)</td><td><span class="ObjectNum">' + zonghanshui.toFixed(2) + '</span></td></tr><tr><td style="min-width:140px;width:140px;" class="text-center">修改后含税金额(元)</td><td><input type="text" id="newhanshui" class="form-control" style="min-width:100px;width:100px;"/><span style="display:none;color:red" id="tshanshui">金额不能为空</span></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" class="btn btn-success" id="qdhanshui" value="确认提交"><input type="button" class="btn btn-warning" value="关闭返回" id="cancelBack" style="margin-left:20px"></div></form>'
					layer.open({
						type: 1,
						title: "TI核销修改含税金额",
						skin: 'layui-layer-rim', //加上边框
						area: ['500px', '300px'], //宽高
						content: str
					});
					var cancelBack = document.getElementById('cancelBack')
					cancelBack.onclick = function() {
						layer.closeAll();
					}
					var newhanshui = document.getElementById("newhanshui")
					newhanshui.onblur = function() {
						if(!isNaN(parseFloat(this.value))) {
							this.value = parseFloat(this.value).toFixed(2);
						} else {
							this.value = "";

						}
					}
					var qdhanshui = document.getElementById('qdhanshui')
					qdhanshui.onclick = function() {
						if($("#newhanshui").val() == "") {
							$("#tshanshui").show();

						} else {
							$("#tshanshui").hide();
							var xian = parseFloat($("#newhanshui").val());
							var bili = xian / hanshuisz;
							$(".cksdid").each(function() {

								if($(this).prop("checked")) {
									var weihes = parseFloat($(this).parent().nextAll().eq(10).html().replace(',', ''));
									var shuilv = parseFloat($(this).parent().nextAll().eq(15).children().val());
									var price = parseFloat(weihes + weihes * shuilv / 100);
									var nejisuanpri = parseFloat(price * bili);
									$(this).parent().nextAll().eq(17).children().val(nejisuanpri.toFixed(2));
									var weishuisa = parseFloat(nejisuanpri / (1 + shuilv / 100));
									var sj = parseFloat(nejisuanpri - weishuisa);
									$(this).parent().nextAll().eq(16).children().val(sj.toFixed(2));
									$(this).parent().nextAll().eq(11).children().val(weishuisa.toFixed(2));
									var vat = $(this).parent().nextAll().eq(14).children().eq(0).children().eq(0).val();
									if(vat == 1)
										var sj = weishuisa;
									else
										var sj = nejisuanpri.toFixed(2);
									$(this).parent().nextAll().eq(18).children().val(sj);
								}
							})
							jisuanzongshu();
							layer.closeAll();
						}
					}
				})
				/*批量设置发票号*/
				$("#setFpNum").click(function() {
					var str = '<form  class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">批量设置发票号</th></tr><tr><td style="min-width:120px;width:120px;" class="text-center">发票号<span class="colorRed">*</span>：</td><td><input type="text" id="tongyifph" class="form-control"/></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" class="btn btn-success" id="fphqd" value="确定"><input type="button" class="btn btn-warning" value="返回" id="cancelBack" style="margin-left:20px"></div></form>'
					layer.open({
						type: 1,
						title: "",
						skin: 'layui-layer-rim', //加上边框
						area: ['500px', '300px'], //宽高
						content: str
					});
					var cancelBack = document.getElementById('cancelBack')
					cancelBack.onclick = function() {
						layer.closeAll();
					}
					var fphqd = document.getElementById('fphqd')
					fphqd.onclick = function() {
						var neirong = $("#tongyifph").val();
						$(".fapiao").each(function() {
							if(!$(this).prop("readonly")) {
								$(this).val(neirong);
							}
						})
						layer.closeAll();
					}
				})
				/*设置发票信息*/
				$("#setFpInfo").click(function() {
					layer.open({
						type: 2,
						skin: 'layui-layer-rim', //加上边框
						area: ['660px', '500px'], //宽高
						content: '{:url("setfapiao")}'
					});
				})
				/*生成核销申请预览*/
				$("#create_verify_yl").click(function() {
					var flag = 0;
					var errortag = 0;
					$(".cksdid").each(function() {
						if($(this).prop("checked")) {
							var isse = $(this).parent().nextAll().eq(12).children().find(".fashi").prop("checked");
							var isno = $(this).parent().nextAll().eq(12).children().find(".fafou").prop("checked");
							if(!(isse || isno)) {

								$(this).parent().nextAll().eq(12).find(".radioDiv").addClass("borRed");
								errortag = 1;
							} else {

								$(this).parent().nextAll().eq(12).find(".radioDiv").removeClass("borRed");
							}
							flag = 1;

						}
					})
					if(flag == 0) {
						swal("", "至少选中一条明细！", "error");
					} else {
						if(errortag == 0) {
							$(".cksdid").each(function() {
								if(!$(this).prop("checked")) {

									$(this).parent().parent().remove();

								}
							})
							document.getElementById("f1").submit();
						} else {
							swal("", "请将红色框内的数据填写完整！", "error");
						}
					}

				});
				$(".num2i").each(function() {
					$(this).html(parseFloat($(this).html()).toFixed(2));
				})
				var $ObjectNum = $(".ObjectNum");
				toNum($ObjectNum);
				weishuigesih();
			});

			function back() {
				history.go(-1)
			}

			function weishuigesih() {
				$(".heweishui").each(function() {
					$(this).val(parseFloat($(this).val()).toFixed(2));
				});
			}
		</script>
	</body>

</html>